1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
|
2020-08-15 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added a basic overview of the `bsdf' rasterizer.
* src/sdf/ftbsdf.c: Added the citation of the original paper
and added a overview of the process for generating SDF
from bitmaps.
2020-08-15 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added a basic overview of the `sdf' rasterizer.
* src/sdf/ftsdf.c: Added the citation of the original paper
and added a overview of the process for generating SDF
from outlines.
* src/sdf/ftsdf.c (sdf_generate_subdivision): Added comment
explaining how the optimization works.
2020-08-13 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Fix gcc compiler warnings.
* src/sdf/ftsdf.c, src/sdf/ftbsdf.c (*): Fix
various compiler warnings, which were caused
mainly due to unused variables and unused functions.
2020-08-13 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Bug fix.
* src/sdf/ftsdf.c (sdf_generate_with_overlaps): The
outside sign will always be 1. And added a missing
`else'.
2020-08-12 Anuj Verma <anujv@iitbhilai.ac.in>
[base] Fix memory leaks due to FreeType internals.
* src/base/ftobjs.c (ft_remove_renderer): Similar to
`ft_add_renderer', remover raster's `glyph_format'
check. Due to this the rasterizers which do not have
`glyph_format' of `FT_GLYPH_FORMAT_OUTLINE' won't get
deallocated (the `raster_done' function is no called).
2020-08-12 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Fix memory leaks.
* src/sdf/ftsdf.c (sdf_generate_with_overlaps): Deallocate
the temporary bitmaps, and all the rest of the arrays.
And also handle the `shape' appropriately so as to not
cause memory leaks.
2020-08-12 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Handle Post-Script fonts for overlap.
* src/sdf/ftsdf.c (sdf_generate_with_overlaps): Handle
Handle Post-Script fonts for overlap support. Simply
flip the orientation while combining all the separate
SDF.
Also, handle the `flip_sign' property separately so as
to avoid handling extra cases.
2020-08-12 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added overlap support (currently only for TrueType).
* src/sdf/ftsdfrend.h (SDF_Renderer_Module): Removed the
expermental `optimization' property.
Added another property `overlaps', which can be used to
turn on the overlap support.
* src/sdf/ftsdf.h (SDF_Raster_Params): Ditto as above.
* src/sdf/ftsdfrend.c (*): Added functionality to set
and get the new `overlaps' property.
* src/sdf/ftsdf.c (sdf_raster_render):
Removed support for all the optimization modes and
only keep the subdivision optimization and the new
overlap support function.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Turned
off until we can find a way to make it faster.
* src/sdf/ftsdf.c (sdf_generate_with_overlaps): Added
a function to generate SDF for shapes with overlapping
contours. It basically generate SDF for separate contours
in seperate bitmaps and then combine them to remove
overlaps.
2020-08-7 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf, bsdf] Added better documentation.
* src/sdf/ftsdf.c, src/sdf/ftbsdf.c (*): Added documentation
of the structs and enums for both the renderers.
2020-08-6 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to get contour orientation.
* src/sdf/ftsdf.c (SDF_Contour_Orientation): Added
enum to hold the different orientations of a contour.
* src/sdf/ftsdf.c (get_contour_orientation): Added
function which can be used to compute the orientation
of a contour.
* src/sdf/ftbsdf.c (*): Remove completed `[TODO]'s.
2020-08-6 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added documentation for functions of the `bsdf' renderer.
* src/sdf/ftbsdf.c (*) Added function documentation for
function of the `bsdf' renderer.
2020-08-6 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added documentation for function of the `sdf' renderer.
* src/sdf/ftsdf.c (*): Added function documentation for
function of the `sdf' renderer, and fixed grammar at a
few places.
2020-08-5 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added documentation for some structs.
* src/sdf/ftsdfrend.h
.../ftsdfrend.c
.../ftsdfcommon.h
.../ftsdf.h
: Added documentation for a few structs.
2020-08-5 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Extended to work with monochrome bitmaps.
* src/sdf/ftbsdf.c (bsdf_init_distance_map): Handle
monochrome bitmaps and convert them to the internal
intermediate format, which can then be used to
generate SDF.
2020-08-3 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (ft_bsdf_render): Initialize
the target bitmap so as to avoid crashes due to
uninitialized memory.
2020-08-3 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Fixed memory leak.
* src/sdf/ftbsdf.c (bsdf_raster_render): Release the
allocated distance map.
Also, added a log of total memory allocated for
generating SDF from bitmap.
2020-08-2 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Fixed a bug with `finalize_sdf'.
* src/sdf/ftbsdf.c (finalize_sdf): First check if the
value is withing [-spread, spread] and then cast it
to 6.10 short, otherwise the value can overflow and
give negative result.
Also, flip the sign if the property `flip_sign' is
set to true.
2020-08-1 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added option to use squared distances.
* src/sdf/ftbsdf.c (bsdf_is_edge): Modified the function
to use distance map rather than the alpha values from
the source image.
* src/sdf/ftbsdf.c (bsdf_approximate_edge): Only calculate
approximate edges for edge pixels. Use `bsdf_is_edge' is
to check for edge pixels. For non edge pixel assgn far
away distances.
* src/sdf/ftbsdf.c (finalize_sdf): Handle distances in case
of squared distances.
And also use the macro `VECTOR_LENGTH_16D16' in the entire
code to compute vector length. This takes care of squared
distances.
* src/sdf/ftsdfcommon.c (VECTOR_LENGTH_16D16): Move the macro
`VECTOR_LENGTH_16D16' from `ftsdf.c' to this file because
it is also used by the `bsdf' renderer.
2020-08-1 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c (compare_neighbor): Fix bug.
2020-08-1 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Optimized a bit.
* src/sdf/ftbsdf.c (ED: sign => alpha): Renamed sign
to alphas. This is used to store the alpha of the current
pixel mapped to the source image. This let's us store
additional information without increasing memory usage.
* src/sdf/ftbsdf.c (bsdf_init_distance_map): Removed any/all
kind of edge approximation and edge check from the function.
The function simply copy the source bitmap to the distance
map now, preserving alpha values.
* src/sdf/ftbsdf.c (compute_edge_distance): Use the new `alpha'
parameter to compute gradient and approximate distance.
Previously we were using the `dist' variable to store alpha
values, which restricts modifying the `dist' variable because
we need alpha values of neighbor to compute the gradient.
* src/sdf/ftbsdf.c (bsdf_approximate_edge): Now that we can
modify the `dist' variable of the distance map, we can
combine the two nested loops.
* src/sdf/ftbsdf.c (finalize_sdf): Move the `sign' determination
and assignment to this function.
2020-07-31 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c (compute_edge_distance): Grammer fix.
2020-07-31 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Add explanation of the approximation.
* src/sdf/ftbsdf.c (compute_gradient => compute_edge_distance):
Renamed to make sense of what the function does.
Also, added the explanation of the algorithm used
and a high level view of how it works.
* src/sdf/ftbsdf.c (compare_neighbor): Fix a bug related
to value approximation before calling `FT_Vector_Length'.
2020-07-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfcommon.h (*): Fix line endings.
Always use LF line endings.
2020-07-30 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf,bsdf] Put common propertied and functions in one file.
* src/sdf/ftsdfcommon.h: Added new file which contains
common function, macros, properties for both `sdf' and
`bsdf' renderer.
* src/sdf/ftsdf.c, src/sdf/ftsdf.h, src/sdf/ftbsdf.c:
Remove common properties and include `ftsdfcommon.h'.
* src/sdf/rules.mk (SDF_DRV_H): Add the new `ftsdfcommon.h'
file to include list.
2020-07-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c (compute_gradient): Use root(2)
for the filter. Also, use the computed gradient
to approximate the edge distance from a pixel's
position according to the Gustavson's algorithm.
2020-07-29 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added function to approximate edge distance.
* src/sdf/ftbsdf.c (bsdf_approximate_edge): The function
uses the Gustavson's algorithm to approximate the edge
from pixel values.
* src/sdf/ftbsdf.c (compute_gradient): The function uses
Sobel's operator to compute the gradient at a pixel.
The is used to detect edge direction.
2020-07-28 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c (_pass): Use function for repetitive task.
Use function `compare_neighbor' for comparing the
neighbors. Makes it easier to tweak the algorithm
and looks better.
* src/sdf/ftbsdf.c (compare_neighbor): Added function
to compare the neighbors and assign values if the
new distance is the shortest.
2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c (bsdf_is_edge): Use macros to
make it look cleaner.
Use `CHECK_NEIGHBOR' macro to check neighbors while
finding edges. Make the code more readable and look
cleaner.
2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Fix edge detection bug.
* src/sdf/ftbsdf.c (bsdf_is_edge): [BUG] Check all
neighbors including the diagonal neighbors to
properly determine the edge.
2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added edge detection algorithm.
Added edge detection algorithm. It works by checking
the neighboring pixels and if any neighbor is not
filled (i.e. belongs to background) we mark the
pixel as edge by setting it's distance to 0.
* src/sdf/ftbsdf.c (bsdf_is_edge): Added function to
detect if the pixel is an edge.
2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added the second pass of the '8SED'.
Added the second pass of the 8SED algorithm. The second pass
transverse the bitmap from bottom to top and for each row
it sweeps forward and backward assigning distances to the
grid points.
* src/sdf/ftbsdf.c (second_pas): Added function to do the
second pass of the 8SED algorithm on the bitmap.
2020-07-26 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Optimize the first pass of the 8SED.
* src/sdf/ftbsdf.c (first_pass): Optimize the first
pass by first approximating the neighbor's distance
by adding an offset. The offset will be max root(2)
because the maximum be add to a vector is (1, 1).
By approximating we can reduce the number of
`FT_Vector_Length' calls and thus make the process
faster.
2020-07-26 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Fix GNU Make build.
* src/sdf/rules.mk (SDF_DRV_H): Manually add source files
as there is a `ftbsdf.c' file without any `ftbsdf.h'.
* src/sdf/ftbsdf.c: Include `fttrigon.h' for `multi' builds.
2020-07-26 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added first pass of the '8SED' algorithm.
Added the first pass of the 8SED algorithm. The first pass
transverse the bitmap from top to bottom and for each row
it sweeps forward and backward assigning distances to the
grid points.
* src/sdf/ftbsdf.c (ED): Added additional parameter `sign'.
* src/sdf/ftbsdf.c (edt8): Added function to convert bitmap
to SDF using the 8SED algorithm.
* src/sdf/ftbsdf.c (first_pass): Added function to do the
first pass of the 8SED algorithm on the bitmap.
* src/sdf/ftbsdf.c (finalize_sdf): Added function to assign
the final SDF data to the target bitmap.
* src/sdf/ftbsdf.c (*): Various minor or experimental changes.
* src/sdf/ftsdfrend.c (ft_bsdf_render): Fix spacing.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c (*): Rename `SDF_TRaster' => `BSDF_TRaster'.
`SDF_TRaster' is for the `sdf' renderer.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c: Typo. `FT_16D16' is 16.16 representation.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf renderer] Hold a refrence to `FT_Memory'.
Due to the way the 8SED algorithm works we need to keep
a track of distances and nearest point of all the pixels/
grid points.
* src/sdf/ftbsdf.c (BSDF_TRaster): Added struct to
hold the `FT_Memory' reference, to be used to allocate
memory.
* src/sdf/ftbsdf.c (ED, BSDF_Worker): Added few more
essential struct. `ED' contains infomation about the
nearest point. `BSDF_Worker' is used to combine all
the essentail parameters to functions.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target =>
bsdf_init_distance_map): Renamed.
* src/sdf/ftbsdf.c (*): Various minor changes.
* src/sdf/sdf.c: Change the order of source include
because `ftsdf.c' change some internal freetype
defines which are required in `ftbsdf.c'.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf renderer] Convert 8bit bitmap to 16bit.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target): Added
extra parameter to flip the bitmap vertically.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target):
Implemented functionality to convert 8bits per
pixel bitmap to a 16bits per pixel bitmap, which
will be used to generate SDF.
2020-07-24 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Started the `bsdf' rasterier.
* src/sdf/ftbsdf.c (*): Fix line endings.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target): Added
function to copy the source bitmap to the center of
the target bitmap and also convert it to normalized
16 bits per pixel bitmap.
2020-07-19 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added interface functions for `bsdf' converter.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Remove
the bitmap check which prevent calling renderers
if the glyph is already a bitmap. The `bsdf' renderer
requires a bitmap for conversion.
* src/base/ftobjs.c (ft_add_renderer): Remove the glyph
format check which ensures that the glyph format for
a renderer is `FT_GLYPH_FORMAT_OUTLINE', again the `bsdf'
renderer has `FT_GLYPH_FORMAT_BITMAP' as a glyph format,
so we need to remove the condition to initialize the
renderer properly.
* src/sdf/ftbsdf.c (*): Added a rasterizer for the
`bsdf' renderer and created necessary functions.
* src/sdf/ftbsdf.h: Add forward declaration of the
rasterizer.
* src/sdf/ftsdfrend.c (ft_bitmap_sdf_renderer_class):
Define the new `bsdf' rendere and add the
`FT_Renderer_RenderFunc' function, the rest is
same as the `sdf' renderer.
* src/sdf/ftsdfrend.h: Add forward declaration of the
renderer.
* src/sdf/rules.mk (SDF_DRV_SRC): Add the new `ftbsdf.c'
file to the compile list.
* src/sdf/sdf.c: Inclue the `ftbsdf.c' file if making
single object.
2020-07-19 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Add alloc/free functions.
* src/sdf/ftsdf.c (*): Add `sdf_alloc' and `sdf_free'
to allocate and deallocate memory respectively.
By using function we can directly use them in the
conditional statements, which is not possible when
using `do {} while ( 0 )'.
* src/sdf/ftsdf.c (SDF_MEMORY_TRACKER_): When not
debugging don't leave the macros empty otherwise
some compiler may emit warning because of empty
`;' semi-colon.
2020-07-19 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added new renderer `bsdf'.
* src/sdf/ftsdfrend.* (*): Added new renderer
named `bsdf' which basically convert bitmap
to signed distance fields. This is a part of
the `sdf' module and not a separate module on
it's own.
* src/sdf/module.mk (FTMODULE_H_COMMANDS): Add
the new renderer to the list of modules.
* include/freetype/config/ftmodule.h: Add the
new renderer to default list of modules when
not compiling with GNU Make.
2020-07-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Only track memory in debug mode.
* src/sdf/ftsdf.c (*): Disable total memory
usage tracking if the program is not in
debug mode.
2020-07-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdfb] Removed Module.
Remove sdfb module. Instead of a new module
simply create a new renderer in the `sdf'
module for converting bitmaps to SDF.
2020-07-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdfb] Fix GNU Make build.
* src/sdfb/rules.mk (SDFB_DRV_H): Fix name of
the module specific error file `ftsdfberrs.h'.
* src/sdf/ftsdf.h (Optimizations): Fix warning.
`warning: comma at end of enumerator list [-Wpedantic]'
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Remove
unused variable `cindex', causes warning.
`warning: unused variable 'cindex' [-Wunused-variable]'
2020-07-17 Anuj Verma <anujv@iitbhilai.ac.in>
[sdfb] Added new module to generate SDF from bitmap.
* src/sdfb/sdfb.c, src/sdfb/ftsdfbrend.c,
src/sdfb/ftsdfb.c, src/sdfb/ftsdfbrend.h,
src/sdfb/ftsdfb.h, src/sdfb/ftsdfberrs.h:
Added files required by the `sdfb' renderer module.
* src/sdfb/rules.mk, src/sdfb/module.mk: Added
files required to build the `sdfb' module using
the default build system.
* CMakeLists.txt (BASE_SRCS): Add `src/sdfb/sdfb.c'
to the variable.
* include/freetype/config/ftmodule.h: Added `sdfb'
module declaration so that the module can be compiled
when not compiling with GNU make.
* modules.cfg (RASTER_MODULES): Include `sdfb' module
to the default rasterizer module list.
* include/freetype/ftmoderr.h: sdfb module error define
* src/sdf/rules.mk: Add EOF.
2020-07-17 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added memory tracker.
* src/sdf/ftsdf.c (SDF_MemoryUser): Added struct
which is used in place of `FT_Memory::user'.
* src/sdf/ftsdf.c (SDF_ALLOC, SDF_FREE): Added macros
for allocating and deallocating memory. These macros
restore the old `FT_Memory::user' before calling the
relevant allocation/deallocation functions so as to
not cause errors while debugging memory. And later
they add the allocated memory size in a variable.
* src/sdf/ftsdf.c (*): Use `SDF_ALLOC', `SDF_FREE'
instead of the `FT_' variant.
2020-07-15 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (sdf_property_set): Minor fix.
2020-07-14 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Temporary change.
Added new property to dynamically change the
optimization to be used to generate the SDF.
This can be used to compare the performance of
different optimization techniques without going
and recompiling the program.
And will also be used in the demo to check the
performance.
2020-07-13 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added more properties.
Added two properties:
- `flip_y': To flip the generated SDF along the y axis.
- `flip_sign': By default outside is treated to have
negative sign, setting `flip_sign' to 1 the outside
pixels will have positive sign.
* src/sdf/ftsdf.* (*): Use the newly added properties.
* src/sdf/ftsdfrend.* (*): Add the newly added properties,
and add functionality to set them using `FT_Property_Set'.
2020-07-13 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Check for left or right fill.
* src/sdf/ftsdf.c (SDF_Params): Added struct which
contains some internal data required by the rater-
izer (such as left/right fill).
* src/sdf/ftsdf.c (sdf_raster_render): Determine the
fill side and pass it to the `sdf_generate_' funcs.
* src/sdf/ftsdf.c (sdf_generate_): Use the new `SDF_Params'
to generate SDF accordingly.
2020-07-12 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Optimize the coarse grid optimization.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Merge
the relevant edge finding loop and shortest dist-
ance search loop. We can find the relevant edges
of a coarse grid and immediately use them to find
the shortest distance of the points in the coarse
grid. This drastically reduce memory usage and
performance.
Also, do the sign assignment of the edges which was
missing.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (*): Fixed warnings.
Fixed various warnings and other few errors.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Comments.
Add more comments explaining the step by step
process of using coarse grid to increase the
performance of nearest distance search.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Memory leak.
Release the allocated lists for the coarse grid after
we are done using them.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Completed the coarse grid optimization.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Fixed
an issue with position calculation and upside down
images.
2020-07-10 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Partially completed the coarse grid optimization.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Added
functionality to check distances of all edges from
the coarse grid and add the relevant edges to the
list.
[Note]: The function is not complete yet.
2020-07-10 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added the coarse grid optimization function.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): The
function uses coarse grid to optimize nearest edge
search performance.
2020-07-10 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Remove use of `FT_List'.
Simply use a `next' pointer inside `SDF_Edge' and
`SDF_Contour' to create a linked list. This reduces
the number of allocations due to `FT_ListNode', also
we don't need a doubly linked list.
* src/sdf/ftsdf.c (SDF_Edge, SDF_Contour): Remove the
`FT_List' and use a `next' pointer to create the
linked list.
* src/sdf/ftsdf.c(sdf_edge_destructor, sdf_contour_destructor):
Removed, not needed any more.
* src/sdf/ftsdf.c (*): Remove the use of `FT_List_'
functions wherever necessary and sync with the new
list.
2020-07-09 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added subdivision optimization.
* src/sdf/ftsdf.c (sdf_generate_subdivision): The
function generate SDF just like the `sdf_generate'
function, but subdivide the curve into a number of
lines and then use the `sdf_generate_bounding_box'
function to generate SDF.
2020-07-09 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to subdivide a cubic curve.
* src/sdf/ftsdf.c (split_cubic, split_sdf_cubic):
These functions can be used to subdivide a
cubic bezier curve into line segments which can
then be used to generate the SDF.
* src/sdf/ftsdf.c (split_sdf_shape): Added function
to split a cubic into a line segments.
* src/sdf/ftsdf.c (sdf_shape_done): No need to pass
`FT_Memory' as a parameter, it can be accessed
from the `shape' struct.
2020-07-09 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (split_sdf_shape): Typo.
2020-07-08 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (split_sdf_shape): Memory leak.
After recursion the edges variable becomes `NULL'
so reassign it to deallocate the list completely.
2020-07-08 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to subdivide a conic curve.
* src/sdf/ftsdf.c (split_conic, split_sdf_conic):
These functions can be used to subdivide a
conic bezier curve into line segments which can
then be used to generate the SDF.
* src/sdf/ftsdf.c (split_sdf_shape): Added function
to split a outline into a line segments.
2020-07-06 Anuj Verma <anujv@iitbhilai.ac.in>
* [GSoC]ChangLog: Fixed typos.
2020-07-06 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (sdf_generate_bounding_box): Due to
the way we use the bounding box, we need to keep a track
of signed distances of each pixel so later the sign can
be determined properly. The method is certainly faster
then checking all the pixels against all the edges,
but also require a decent amount of memory to work.
2020-07-06 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Precompute the orthogonality.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Remove unused
fields.
* src/sdf/ftsdf.c (resolve_corner): The function can be
simplified to a single line. Instead of computing
orthogonality here, we precompute it in the corresponding
`get_min_distance_' functions more efficiently.
* src/sdf/ftsdf.c (get_min_distance_): Precompute orthogonality/
cross product of direction and the distance vector. Since
in these function we know that weather the distance vector
and the direction are perpendicular, we can simply set
the cross to 1 (sin(90) = 1) in case they are perpendicular.
This can reduce the number of `FT_Vector_NormLen' calls.
2020-07-05 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added bounding box optimization.
* src/sdf/ftsdfrend.c (sdf_generate_bounding_box): The
function generate SDF just like the `sdf_generate'
function, but uses bounding box to check pixels
efficiently.
* src/sdf/ftsdfrend.c (get_control_box): Added function
to get control box of a `SDF_Edge'.
2020-07-04 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (sdf_shape_dump): Use `%ld' to
printf `signed long' otherwise it gives wrong output.
2020-07-04 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (ft_sdf_render): Don't negate
unsigned integers.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c: Use ASCII single quote (') instead
of back tick (`) for derivatives. Looks cleaner.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to find shortest distance from a
point to a cubic bezier. Now the sdf module can render
all types of fonts, but still has some issues.
* src/sdf/ftsdf.c (get_min_distance_cubic): The function
calculates shortest distance from a point to a cubic
bezier curve.
* src/sdf/ftsdf.c (sdf_edge_get_min_distance): Add the
`get_min_distance_cubic' function call.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (resolve_corner): [Bug] Remove the
nearest_point check. Two distances can be same and
can give opposite sign, but they may not have a
common nearest_point. Also remove distance check
because due to precision errors the two distances can
be really really close. Therefore use epsilon instead.
* src/sdf/ftsdf.c (sdf_contour_get_min_distance): Use
epsilon for comparing distances.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_shape_dump): Add more info
to the debug output.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (MAX_NEWTON_ITERATION => MAX_NEWTON_DIVISIONS):
Renamed to avoid confusion.
2020-07-02 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added Newton's method for shortest distance
from a point to a conic.
* src/sdf/ftsdf.c (get_min_distance_conic): Created
a new function with same name which uses Newton's
iteration for finding shortest distance from a point
to a conic curve. This doesn't causes underflow.
* src/sdf/ftsdf.c (USE_NEWTON_FOR_CONIC): This macro
can be used to toggle between Newton or analytical
cubic solving method.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (get_min_distance_conic): Add more
details to why we clamp the roots.
* src/sdf/ftsdf.c: Make sure preprocessor # is always
on the first line.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Make squared distances toggleable.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Renamed
squared_distance to distance. It can now represent
both squared as well as actual distances.
* src/sdf/ftsdf.c (USE_SQUARED_DISTANCES): Added macro
which control weather to do computation is squared
distances or actual distances. This can be used to
avoid overflow when generating large SDF bitmaps.
* src/sdf/ftsdf.c: Make sure not to exceed line length
of 78.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (get_min_distance_conic): In case
the cubic equation returns zero root, use endpoints
for calculating the shortest distance.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to find shortest distance from a
point to a conic bezier. Now the sdf module can render
ttf fonts or fonts with line and conic segments.
* src/sdf/ftsdf.c (get_min_distance_conic): The function
calculates shortest distance from a point to a conic
bezier curve.
* src/sdf/ftsdf.c (sdf_edge_get_min_distance): Add the
`get_min_distance_conic' function call.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (get_min_distance_line): First check
pointer before using or dereferencing them.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c: Avoid parentheses if there is only
one statement inside a control-flow statement.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to solve polynomial equations.
* src/sdf/ftsdf.c (solve_quadratic_equation,
solve_cubic_equation): Added functions to solve
quadratic and cubic equations. These will be used for
conic bezier curves only.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (square_root, cube_root, arc_cos):
Use FT_16D16 instead of FT_Fixed to avoid confusion.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (cube_root, arc_cos): Added a few
essential math functions.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Fixed compilation under gnumake.
* src/sdf/rules.mk (DRV_OBJ_ => DRV_OBJS_): Fixed variable
name so that the sdf can compile.
* src/sdf/module.mk: Fixed spacing.
* src/sdf/*.c: Fixed all compiler warnings.
* [GSoC]ChangLog: Fixed dates.
2020-06-29 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to resolve corners in case of
ambiguity.
* src/sdf/ftsdf.c (resolve_corner): Added function
to determine the correct sign in case there are
two sign for the same shortest distance (happens
around corners).
* src/sdf/ftsdf.c: Typo neartest_point -> nearest_point.
2020-06-29 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] The module can now generate signed distance
fields for outline with only lines.
* src/sdf/ftsdf.c (get_min_distance_line): Calculation
mistake.
* src/sdf/ftsdf.c (square_root): Added function to calculate
square root of a 16.16 fixed point integer.
* src/sdf/ftsdf.c (sdf_generate): Assign values to the output
bitmap, currently the output is 6.10 fixed point which can
contain values from [-32, 32]. Also fixed a bug which was
causing upside down images.
* src/sdf/ftsdfrend.c (ft_sdf_render): Fixed alignment issues.
2020-06-28 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to find shortest distance from
a point to a line.
* src/sdf/ftsdf.c (get_min_distance_line): The function
calculate the shortest signed distance from a point
to a line segment.
* src/sdf/ftsdf.c (sdf_contour_get_min_distance): Typo.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Use squared
distance instead of actual distance for performance.
2020-06-28 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (SDF_Iterator_IO): Removed.
* src/sdf/ftsdf.c (sdf_edge_iterator_func => sdf_edge_get_min_distance
sdf_contour_iterator_func => sdf_contour_get_min_distance): Renamed.
Manually iterate through the lists instead of `FT_List_Iterate' to
avoid io structs and looks a bit cleaner.
2020-06-28 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added basic outline of the functions required to
generate sdf.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Added struct which
represent a complete signed distance and can be used to
get cross, dot, sign etc.
* src/sdf/ftsdf.c (SDF_Iterator_IO): This struct will be used
while `FT_List_Iterate'.
* src/sdf/ftsdf.c (sdf_generate): Added function which generate
SDF from `SDF_Shape'.
* src/sdf/ftsdf.c (sdf_edge_iterator_func,
sdf_contour_iterator_func): Added functions
which iterate through contours and edges and return the shortest
distance.
2020-06-27 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added `SDF_Raster_Params' struct which extends
`FT_Raster_Params' and has a few extra fields. This is done
to pass extra data to the sdf rasterizer which is required
while rasterizing.
* src/sdf/ftsdf.h (SDF_Raster_Params): Added a struct which
extends `FT_Raster_Params' and has the `spread' parameter.
Also moved the max, min and default spread values to this
header file.
* src/sdf/ftsdf.c (sdf_raster_render): Added parameter and
attribute checking in order to pick errors and return
early.
* src//sdf/ftsdfrend.c (ft_sdf_render): Setup the `SDF_Raster_Params'
and pass it to the rasterizer instead of `FT_Raster_Params'.
2020-06-27 Anuj Verma <anujv@iitbhilai.ac.in>
* include/freetype/ftimage.h (FT_RASTER_FLAG_): Added
a new raster flag `FT_RASTER_FLAG_SDF'. The `ftsdf'
rasterizer will only render if this flag is set.
* src/sdf/ftsdfrend.c (ft_sdf_render): Set the `flags' field
of `FT_Raster_Params' to `FT_RASTER_FLAG_SDF'.
2020-06-26 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_shape_dump): Use `FT_TRACEX'
instead of `printf'.
2020-06-26 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_shape_dump): Added function to
dump the `SDF_Shape' on the console for debugging.
2020-06-26 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to de-allocate `SDF_' structs.
* src/sdf/ftsdf.c (SDF_Contour, SDF_Shape): Use `FT_ListRec'
instead of `FT_List' to avoid a few extra allocations.
* src/sdf/ftsdf.c (SDF_Edge, SDF_Contour, SDF_Shape): Added
functions to de-allocate these structs and their members.
* src/sdf/ftsdfrenc.c: Typo.
2020-06-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Decompose outline and store it in a temporary
`SDF_Shape' object for easy iteration and pre-computing
some variables.
* src/sdf/ftsdf.c (sdf_outline_decompose): Added function
to decompost outline and store it in a `SDF_Shape' object.
This allows us to pre-compute some variable.
2020-06-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added essential enums and structs required.
* src/freetype/internal/fttrace.h: Remove tabs.
* src/sdf/ftsdfrend.c (ft_sdf_render): Calculate padding
using the `spread'.
* src/sdf/ftsdf.c (SDF_Edge_Type, SDF_Edge, SDF_Contour,
SDF_Shape): Added structures and their initializer
functions.
2020-06-23 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functionality to set and get module properties.
Also added a `spread' property.
* src/freetype/internal/fttrace.h: Added sdf module trace
define.
* src/sdf/ftsdf.c (sdf_TRaster => SDF_TRaster): Use capital
character for structs.
* src/sdf/ftsdfrend.h (SDF_Renderer_Module): Added a struct
which extends the `FT_RendererRec' and added the `spread'
property.
* src/sdf/ftsdfrend.c: Synchronized the code to use the new
`SDF_Renderer_Module' and added functions to get/set the
properties.
2020-06-20 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Implemented a few functions required by a renderer
module.
* src/sdf/ftsdf.c (sdf_TRaster_): Added new structure to hold
the memory allocator `FT_Memory'.
* src/sdf/ftsdf.c (ft_sdf_raster): Implemented a few essential
functions required by `FT_Raster'.
* src/sdf/ftsdfrend.c (ft_sdf_renderer_class): Implemented a few
essential functions required by `FT_Renderer'.
* src/sdf/ftsdfrend.c (ft_sdf_render): Added functionality to
compute shift and padding before rendering the outline.
2020-06-19 Anuj Verma <anujv@iitbhilai.ac.in>
* include/freetype/ftimage.h (FT_Render_Mode_): Added new
pixel mode `FT_PIXEL_MODE_GRAY16' which will be used
to represent signed values while rendering to SDF bitmap.
2020-06-19 Anuj Verma <anujv@iitbhilai.ac.in>
* include/freetype/freetype.h (FT_Render_Mode_): Added new
rendermode `FT_RENDER_MODE_SDF' which will be used by the
`sdf' module to generate signed distance fields from glyph's
outline.
* src/sdf/ftsdfrend.h, src/sdf/module.mk, src/sdf/rules.mk:
Add a new line at the end of files.
2020-06-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added the structure of a new module to render
signed distance fields.
* src/sdf/sdf.c, src/sdf/ftsdfrend.c, src/sdf/ftsdf.c,
src/sdf/ftsdfrend.h, src/sdf/ftsdf.h, src/sdf/ftsdferrs.h:
Added files required by the `sdf' renderer module and added
the basic structure and functions required.
* src/sdf/rules.mk, src/sdf/module.mk: Added files required to
build the `sdf' module using the default build system.
* CMakeLists.txt (BASE_SRCS): Add `src/sdf/sdf.c' to the variable.
* include/freetype/config/ftmodule.h: Added `sdf' module
declaration so that the module can be compiled when not compiling
with GNU make.
* modules.cfg (RASTER_MODULES): Include `sdf' module to the default
rasterizer module list.
* include/freetype/ftmoderr.h: sdf module error define
|